package com.corpgovernment.common.enums;

import java.util.Arrays;
import java.util.Objects;

public enum CommonEnum {

    Y(true, "是"),

    N(false, "否");

    private Boolean code;
    private String desc;

    CommonEnum(Boolean code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public Boolean getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static CommonEnum getByCode(String code) {
        return Arrays.stream(CommonEnum.values()).filter(e -> Objects.equals(code, e.code)).findFirst().orElse(null);
    }
}
